package com.chinasofti.serivce.impl;

import com.chinasofti.annotation.RedisCache;
import com.chinasofti.annotation.RedisEvict;
import com.chinasofti.dao.UserinfoMapper;
import com.chinasofti.model.Userinfo;
import com.chinasofti.model.UserinfoCriteria;
import com.chinasofti.service.UserinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("userinfoService")
public class UserinfoServiceImpl  implements UserinfoService {

    @Autowired
    private UserinfoMapper userinfoMapper  ;


    @RedisCache(type=UserinfoServiceImpl.class)
    public void add(Userinfo userinfo) {
        userinfoMapper.insert(userinfo) ;
    }


    @RedisEvict(type=UserinfoServiceImpl.class)
    public void edit(Userinfo userinfo) {
        userinfoMapper.updateByPrimaryKeySelective(userinfo) ;
    }


    public void deleteById(int id) {
        userinfoMapper.deleteByPrimaryKey(id) ;
    }
    @RedisCache(type=UserinfoServiceImpl.class)
    public List<Userinfo> findAll() {
        UserinfoCriteria userinfoCriteria=new UserinfoCriteria() ;
        return userinfoMapper.selectByExample(userinfoCriteria);
    }
}
